import {
  BwComPropSetConstValueComEnum,
  BwCustomComPropDataTypeEnum,
  BwCustomComEmitParamDataTypeEnum,
  BwCustomComSlotParamDataTypeEnum,
  BwCustomComSoltTypeEnum,
} from '../../../render/models'
import type {
  BwCustomComEmitInfoModel,
  BwCustomComSlotInfoModel,
  BwCustomComPropInfoModel,
} from '../../../render/models'

/** 组件属性 */
const comAttrs: Array<BwCustomComPropInfoModel> = [
  {
    key: 'class',
    name: 'classNames',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'show',
    name: '是否显示(v-model)',
    isModel: true,
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'overlay',
    name: '是否显示遮罩层',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'position',
    name: '弹出位置',
    isRequire: false,
    defaultValue: 'center',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '顶部',
          value: 'top',
        },
        {
          label: '底部',
          value: 'bottom',
        },
        {
          label: '右侧',
          value: 'right',
        },
        {
          label: '左侧',
          value: 'left',
        },
        {
          label: '中心',
          value: 'center',
        },
      ],
    }),
    remark: '',
  },
  {
    key: 'overlay-class',
    name: '自定义遮罩层类名',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.array,
      BwCustomComPropDataTypeEnum.object,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'overlay-style',
    name: '自定义遮罩层样式',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.object],
    defaultValueDataType: BwCustomComPropDataTypeEnum.object,
    constValueSetCom: BwComPropSetConstValueComEnum.textarea,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'duration',
    name: '动画时长',
    isRequire: false,
    defaultValue: '0.3',
    dataType: [
      BwCustomComPropDataTypeEnum.number,
      BwCustomComPropDataTypeEnum.string,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'z-index',
    name: '将弹窗的z-index层级设置为一个固定值',
    isRequire: false,
    defaultValue: '2100',
    dataType: [
      BwCustomComPropDataTypeEnum.number,
      BwCustomComPropDataTypeEnum.string,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.number,
    constValueSetCom: BwComPropSetConstValueComEnum.number,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'round',
    name: '是否显示圆角',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'lock-scroll',
    name: '是否锁定背景滚动',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'lazy-render',
    name: '是否在显示弹层时才渲染节点',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'close-on-popstate',
    name: '是否在页面回退时自动关闭',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'close-on-click-overlay',
    name: '是否在点击遮罩层后关闭',
    isRequire: false,
    defaultValue: 'true',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'closeable',
    name: '是否显示关闭图标',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'close-icon',
    name: '关闭图标名称或图片链接',
    isRequire: false,
    defaultValue: 'cross',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'close-icon-position',
    name: '关闭图标位置',
    isRequire: false,
    defaultValue: 'top-right',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.select,
    constValueSetComProps: JSON.stringify({
      options: [
        {
          label: '上左',
          value: 'top-left',
        },
        {
          label: '下左',
          value: 'bottom-left',
        },
        {
          label: '上右',
          value: 'top-right',
        },
        {
          label: '下右',
          value: 'bottom-right',
        },
      ],
    }),
    remark: '',
  },
  // {
  //   key: 'before-close',
  //   name: '关闭前的回调函数',
  //   isRequire: false,
  //   defaultValue: undefined,
  //   dataType: [BwCustomComPropDataTypeEnum.function],
  //   defaultValueDataType: BwCustomComPropDataTypeEnum.function,
  //   constValueSetCom: BwComPropSetConstValueComEnum.function,
  //   constValueSetComProps: null,
  //   remark: '',
  // },
  {
    key: 'icon-prefix',
    name: '图标类名前缀',
    isRequire: false,
    defaultValue: 'van-icon',
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'transition',
    name: '动画类名',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.string],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'transition-appear',
    name: '是否在初始渲染时启用过渡动画',
    isRequire: false,
    defaultValue: undefined,
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'teleport',
    name: '指定挂载的节点',
    isRequire: false,
    defaultValue: undefined,
    dataType: [
      BwCustomComPropDataTypeEnum.string,
      BwCustomComPropDataTypeEnum.object,
    ],
    defaultValueDataType: BwCustomComPropDataTypeEnum.string,
    constValueSetCom: BwComPropSetConstValueComEnum.input,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'safe-area-inset-top',
    name: '是否开启顶部安全区适配',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
  {
    key: 'safe-area-inset-bottom',
    name: '是否开启底部安全区适配',
    isRequire: false,
    defaultValue: 'false',
    dataType: [BwCustomComPropDataTypeEnum.boolean],
    defaultValueDataType: BwCustomComPropDataTypeEnum.boolean,
    constValueSetCom: BwComPropSetConstValueComEnum.switch,
    constValueSetComProps: null,
    remark: '',
  },
]

/** 组件事件 */
const comEmits: Array<BwCustomComEmitInfoModel> = [
  {
    key: 'update:show',
    name: '是否显示弹出层',
    isModel: true,
    params: [
      {
        paramKey: 'value',
        paramName: '是否显示弹出层',
        paramDataType: BwCustomComEmitParamDataTypeEnum.boolean,
        remark: '',
      },
    ],
  },
  {
    key: 'click',
    name: '点击弹出层时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click-overlay',
    name: '点击遮罩层时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'click-close-icon',
    name: '点击关闭图标时触发',
    params: [
      {
        paramKey: 'event',
        paramName: 'MouseEvent',
        paramDataType: BwCustomComEmitParamDataTypeEnum.object,
        remark: '',
      },
    ],
  },
  {
    key: 'open',
    name: '打开弹出层时立即触发',
    params: [],
  },
  {
    key: 'close',
    name: '关闭弹出层时立即触发',
    params: [],
  },
  {
    key: 'opened',
    name: '打开弹出层且动画结束后触发',
    params: [],
  },
  {
    key: 'closed',
    name: '关闭弹出层且动画结束后触发',
    params: [],
  },
]

/** 组件插槽 */
const comSlots: Array<BwCustomComSlotInfoModel> = [
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'default',
      slotName: '弹窗内容插槽',
    },
  },
  {
    slotType: BwCustomComSoltTypeEnum.convention,
    conventionSlotInfo: {
      slotCode: 'overlay-content',
      slotName: '遮罩层的内容插槽',
      slotParams: [],
    },
  },
]

export const vantPopupInfo = {
  comAttrs,
  comEmits,
  comSlots,
}
